package path;

import java.io.Serializable;

@SuppressWarnings("serial")
public class BranchNode implements Serializable {
	private String className;
	private String methodName;
	//-2:ExitNode,-1:VirtualNode
	public int branchNum;
	private int branchGo;
	private BranchNode left; //left children
	private BranchNode right; //right children
	public BranchNode exitNode;
	public int elseIndex = -1;
	//if:1 ;while:2 ;switch 3;-1
	public int type = 0;
	public boolean visited = false;
	
	public static int gid = 0;
	public int id = 0;
	
	public BranchNode(String className, String methodName, int branchNum, int branchGo){
		this.className = className;
		this.methodName = methodName;
		this.branchNum = branchNum;
		this.branchGo = branchGo;
		this.left = null;
		this.right = null;
		id = gid++;
	}
	
	public void addLeft(BranchNode left){
		this.left = left;
	}
	
	public void addRight(BranchNode right){
		this.right = right;
	}
	
	public BranchNode getLeft(){
		return left;
	}
	
	public BranchNode getRight(){
		return right;
	}
	
	public boolean equals(Object obj){
		return this.toString().equals(obj.toString());
	}
	
	public String toString(){
		return className+" "+methodName+" "+branchNum+" "+branchGo;
	}
}
